<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">

    <ui:define name="head">

    </ui:define>
    <ui:define name="content">
        <div style="margin:5px">
            <p:tabView id="tabview" dynamic="true" cache="false" style="font-weight:normal;font-style:normal">
                <p:tab title="【入库信息】新增表单">
                    <h:form id="myForm">
                        <div id="qrytable">
                            <p:growl id="msgs" showDetail="false"/>
                            <p:panel style="margin-top:30px" id="addPanel">
                                <h:panelGrid columns="4" cellspacing="5">
                                    <h:outputLabel   value="入库编码:"/>
                                    <p:inputText required="true" value="#{inAction.oaIn.inCode}" readonly="true"/>
                                    <h:outputLabel value="入库日期:" for="inDate"/>
                                    <p:inputText id="inDate" required="true" value="#{inAction.oaIn.inDate}"
                                                 onclick="WdatePicker({dateFmt:'yyyyMMdd'})"/>
                                    <h:outputLabel required="true" value="购买人:"/>
                                    <p:inputText required="true" value="#{inAction.oaIn.buyer}"/>
                                    <h:outputLabel value="采购日期:" for="buyDate"/>
                                    <p:inputText id="buyDate" required="true" value="#{inAction.oaIn.buyDate}"
                                                 onclick="WdatePicker({dateFmt:'yyyyMMdd'})"/>
                                    <h:outputLabel value="客户名称" for="custCode"/>
                                    <h:panelGroup>
                                        <h:selectOneMenu id="custCode" style="width:130px;"
                                                         value="#{inAction.oaIn.custCode}">
                                            <f:selectItems value="#{inAction.listCustomer}"/>
                                        </h:selectOneMenu>
                                    </h:panelGroup>
                                    <h:outputLabel value="采购类型:"/>
                                    <p:inputText required="true" value="#{inAction.oaIn.buyType}"/>
                                    <h:outputLabel value="备注:"/>
                                    <p:inputText required="true" value="#{inAction.oaIn.remark}"/>
                                </h:panelGrid>
                                <p:separator  style="margin-top:30px"/>
                                <h:panelGrid columns="4" cellspacing="5">
                                    <p:commandButton style="width:120px;" value="提交" action="#{inAction.insertRecord}"
                                                     update="msgs,myTable">
                                    </p:commandButton>

                                    <p:commandButton style="width:120px;" value="重置" action="#{inAction.reset}"
                                                     update="addPanel,myTable">
                                    </p:commandButton>
                                </h:panelGrid>
                            </p:panel>
                            <p:ajaxStatus style="height:18px;text-align:center">
                                <f:facet name="start">
                                    <h:graphicImage value="/images/ajaxloadingbar.gif"/>
                                </f:facet>
                                <f:facet name="complete">
                                    <h:outputText value=""/>
                                </f:facet>
                            </p:ajaxStatus>

                            <p:dataTable id="myTable" value="#{inAction.listOaIndetail}" selectionMode="single"
                                         var="record"
                                         rowKey="#{record.id}}"
                                         selection="#{inAction.selectedOaIndetailRecords}"
                                         editable="true">

                                <p:ajax event="rowEdit" listener="#{inAction.onEdit}" update=":tabview:myForm:msgs"/>
                                <p:ajax event="rowEditCancel" listener="#{inAction.onCancel}" update=":tabview:myForm:msgs"/>

                                <p:column headerText="物品名称" style="width:125px">
                                    <p:cellEditor>
                                        <f:facet name="output">
                                            <h:outputText value="#{flagStatusForMap.mapGoods[record.goodsId]}" />
                                        </f:facet>
                                        <f:facet name="input">
                                            <p:inputText value="#{record.goodsCode}" style="width:100%"/>
                                        </f:facet>
                                    </p:cellEditor>
                                </p:column>

                                <p:column headerText="物品单价" style="width:125px">
                                    <p:cellEditor>
                                        <f:facet name="output">
                                            <h:outputText value="#{record.goodsPrice}" />
                                        </f:facet>
                                        <f:facet name="input">
                                            <p:inputText value="#{record.goodsPrice}" style="width:100%" label="Year"/>
                                        </f:facet>
                                    </p:cellEditor>
                                </p:column>

                                <p:column headerText="物品数量" style="width:125px">
                                    <p:cellEditor>
                                        <f:facet name="output">
                                            <h:outputText value="#{record.goodsCount}" />
                                        </f:facet>
                                        <f:facet name="input">
                                            <p:inputText value="#{record.goodsCount}" style="width:100%" label="Year"/>
                                        </f:facet>
                                    </p:cellEditor>
                                </p:column>

                                <p:column headerText="物品金额" style="width:125px">
                                    <p:cellEditor>
                                        <f:facet name="output">
                                            <h:outputText value="#{record.goodsAmount}" />
                                        </f:facet>
                                        <f:facet name="input">
                                            <p:inputText value="#{record.goodsAmount}" style="width:100%" label="Year"/>
                                        </f:facet>
                                    </p:cellEditor>
                                </p:column>

                                <p:column headerText="仓库名称" style="width:125px">
                                    <p:cellEditor>
                                        <f:facet name="output">
                                            <h:outputText value="#{record.whCode}" />
                                        </f:facet>
                                        <f:facet name="input">
                                            <p:inputText value="#{record.whCode}" style="width:100%" label="Year"/>
                                        </f:facet>
                                    </p:cellEditor>
                                </p:column>

                                <p:column headerText="Options" style="width:50px">
                                    <p:rowEditor />
                                </p:column>
                                <f:facet name="footer">
                                    <!--rendered="#{inAction.mainFlag}"-->
                                    <p:commandButton id="btnAdd" value="新增物品" action="#{inAction.prepareForInsert}"
                                                     rendered="#{inAction.mainFlag}"
                                                     style="align:left"
                                                     update=":tabview:myForm:myPanel" oncomplete="goodsDialog.show()"/>
                                </f:facet>
                            </p:dataTable>
                            <p:dialog header="物品明细" widgetVar="goodsDialog" resizable="false" id="carDlg"
                                      showEffect="fade" hideEffect="explode" modal="true">
                                <h:panelGrid id="myPanel" columns="2" resizable="false">
                                    <h:outputLabel value="物品名称"/>
                                    <h:panelGroup>
                                        <h:selectOneMenu style="width:130px;"
                                                value="#{inAction.oaIndetail.goodsId}"
                                                update=":tabview:myForm:myTable"
                                                onchange="submit()"
                                                valueChangeListener="#{inAction.getGoodsInfo}">
                                            <f:selectItems value="#{inAction.listGoods}"/>
                                        </h:selectOneMenu>
                                    </h:panelGroup>
                                    <h:outputLabel value="物品单价"/>
                                    <p:inputText id="fld2" value="#{inAction.oaIndetail.goodsPrice}" />
                                    <h:outputLabel value="物品数量"/>
                                    <p:inputText id="fld3" value="#{inAction.oaIndetail.goodsCount}" />
                                    <h:outputLabel value="物品金额"/>
                                    <p:inputText id="fld4" value="#{inAction.oaIndetail.goodsAmount}" />
                                    <h:outputLabel value="仓库名称"/>
                                    <p:inputText id="fld5" value="#{inAction.oaIndetail.whCode}" />
                                    <p:commandButton value="提交" action="#{inAction.insertDetailRecord}"
                                        update=":tabview:myForm:myTable" oncomplete="goodsDialog.hide()"/>
                                </h:panelGrid>
                            </p:dialog>
                        </div>
                    </h:form>
                </p:tab>
            </p:tabView>
        </div>
    </ui:define>
</ui:composition>